//
//  BaseBridgeModule.m
//  eCourseApp
//
//  Created by andrew on 2018/8/10.
//  Copyright © 2018年 Facebook. All rights reserved.
//

#import "BaseBridgeModule.h"

@implementation BaseBridgeModule

RCT_EXPORT_METHOD(showPackageName:(NSString *)msg
                  resolver:(RCTPromiseResolveBlock)resolve
                  rejecter:(RCTPromiseRejectBlock)reject){
  resolve(msg);
}

RCT_EXPORT_METHOD(backToExue){
  dispatch_async(dispatch_get_main_queue(), ^{
    [[NSNotificationCenter defaultCenter] postNotificationName:@"backToLogin" object:nil userInfo:nil];
  });
}

RCT_EXPORT_METHOD(goToBookDetail:(NSString *)bookId
                  title:(NSString *)title){

  dispatch_async(dispatch_get_main_queue(), ^{
    [[NSNotificationCenter defaultCenter] postNotificationName:@"goToBookDetail" object:nil userInfo:@{@"title": title ?: @"", @"bookId": bookId ?: @""}];
  });

}

RCT_EXPORT_METHOD(goToReadPage:(NSString *)bookId
                  chapterId:(NSString *)chapterId){
  
  if (chapterId || [chapterId isEqualToString:@""]) {
    chapterId = @"0";
  }
  
  dispatch_async(dispatch_get_main_queue(), ^{
    [[NSNotificationCenter defaultCenter] postNotificationName:@"goToReadPage" object:nil userInfo:@{@"chId": chapterId ?: @"", @"bookId": bookId ?: @""}];
  });
  
}


RCT_EXPORT_METHOD(closeCurrentController){
  
  dispatch_async(dispatch_get_main_queue(), ^{
    [[NSNotificationCenter defaultCenter] postNotificationName:@"closeCurrentController" object:nil userInfo:nil];
  });
  
}


//从原生页跳转到  搜索页

//从rn搜索页，分类w搜索页跳到详情页




RCT_EXPORT_MODULE(BaseBridge);

@end



